﻿using System;

namespace Bettzueche.Dampfross
{
    /// <summary>
    /// Zustands-Aktions-Paar
    /// </summary>
    [Serializable]
    class SATupel : Tuple<int, HexRichtungen>
    {
        /// <summary>
        /// Gibt den Gewichtungswert (q-Wert).<para>
        /// Äquvalent zu <c>Item1</c>.</para>
        /// </summary>
        public int S { get { return base.Item1; } }

        /// <summary>
        /// Gibt den Lohnberechtungswert (eligibility-Wert)<para>
        /// Äquvalent zu <c>Item2</c>.</para>
        /// </summary>
        public HexRichtungen A { get { return base.Item2; } }

        /// <summary>
        /// Initializes a new instance of the <see cref="SATupel" /> class.
        /// </summary>
        /// <param name="ZustandsID">The zustands identifier.</param>
        /// <param name="aktion">The aktion.</param>
        public SATupel(int ZustandsID, HexRichtungen aktion)
            : base(ZustandsID, aktion) {
        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode() {
            return (37 * (int)base.Item2) ^ base.Item1;
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object">object</see>, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj) {
            SATupel other = obj as SATupel;
            return other == null ? false : this.Equals(other);
        }

        public bool Equals(SATupel other) {
            return (this.Item2 == other.Item2) && (this.Item1 == other.Item1);
        }

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString() {
            return String.Format("(S:{0}, A:{1})", Item1, Item2);
        }
    }
}
